package br.igk.isnmp.test;

import java.net.InetAddress;
import java.util.Map;

import br.igk.isnmp.util.SNMPConnection;
import br.igk.isnmp.util.SNMPEntry;

public class SNMPSample2 {

	public static void main(String args[]) {

		try {
			InetAddress hostAddress = InetAddress.getByName("localhost");
			String community = "public";
			int version = 0;

			SNMPConnection con = new SNMPConnection(version, hostAddress, community);
			String[] itemIDs = {"1.3.6.1.2.1.1.1.0", "1.3.6.1.2.1.1.2.0", "1.3.6.1.2.1.1.3.0", "1.3.6.1.2.1.1.4.0", "1.3.6.1.2.1.1.5.0"};
			Map<String, SNMPEntry> newVars = con.getEntry(itemIDs);

			for (String key : newVars.keySet())
				System.out.println("Recebendo: " + newVars.get(key).toJsonString());

			String baseID = "1.3.6.1.2.1.1.";
			System.out.println("Retrieving table corresponding to base OID " + baseID);
			Map<String, SNMPEntry> tableVars = con.getTableEntry(baseID);
			System.out.println("Number of table entries: " + tableVars.size());

			for (String key : tableVars.keySet())
				System.out.println(tableVars.get(key).toJsonString());

			con.close();
		} catch (Exception e) {
			System.out.println("Exception during SNMP operation:  " + e + "\n");
		}

	}

}